bool isBipartite(int** graph, int graphSize, int* graphColSize) {
    int* colors = (int*)malloc(sizeof(int) * graphSize);
    for (int i = 0; i < graphSize; ++i) {
        colors[i] = 0;
    }

    for (int i = 0; i < graphSize; ++i) {
        // 如果当前节点尚未染色，则将其染成1，并将其相邻节点染成-1
        if (colors[i] == 0) {
            colors[i] = 1;
            int* queue = (int*)malloc(sizeof(int) * graphSize);
            int front = 0, rear = 0;
            queue[rear++] = i;

            while (front < rear) {
                int node = queue[front++];
                int neighborColor = -colors[node];

                for (int j = 0; j < graphColSize[node]; ++j) {
                    int neighbor = graph[node][j];
                    if (colors[neighbor] == 0) {
                        colors[neighbor] = neighborColor;
                        queue[rear++] = neighbor;
                    }
                    else if (colors[neighbor] != neighborColor) {
                        free(queue);
                        free(colors);
                        return false;
                    }
                }
            }

            free(queue);
        }
    }

    free(colors);
    return true;
}